import { createRouter, createWebHistory } from 'vue-router'
import { usePopStore } from '@/stores'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'Index',
      redirect: '/overView',
      component: () => import('@/views/Index.vue'),
      children: [
        {
          path: 'overView',
          name: 'OverView',
          meta: { title: '空域总览' },
          component: () => import('@/views/low-altitude-overview/Index.vue')
        },
        {
          path: 'management',
          name: 'Management',
          meta: { title: '空域管理' },
          component: () => import('@/views/management/Index.vue')
        },
        {
          path: 'hanxian',
          name: 'Hangxian',
          meta: { title: '航路航线' },
          component: () => import('@/views/hangxian/Index.vue')
        },
        {
          path: 'infrastructure',
          name: 'Infrastructure',
          meta: { title: '基础设施' },
          component: () => import('@/views/infrastructure/Index.vue')
        },
        {
          path: 'operation',
          name: 'Operation',
          meta: { title: '运营管理' },
          component: () => import('@/views/operation/Index.vue')
        },
        {
          path: 'industry',
          name: 'Industry',
          meta: { title: '低空产业' },
          component: () => import('@/views/industry/Index.vue')
        }
      ]
    }
  ]
})

router.beforeEach((to) => {
  const popStore = usePopStore()
  popStore.closeAllPop()
})

export default router
